package com.tontron.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tontron.system.domain.SysTenant;
import com.tontron.system.service.SysTenantService;
import com.tontron.system.mapper.SysTenantMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.util.List;

/**
* @author xfdukun
* @description 针对表【sys_tenant(租户表)】的数据库操作Service实现
* @createDate 2024-07-05 13:15:55
*/
@Service
public class SysTenantServiceImpl extends ServiceImpl<SysTenantMapper, SysTenant>
    implements SysTenantService{

    @Resource
    private SysTenantMapper sysTenantMapper;

    @Override
    public IPage<SysTenant> listByPage(IPage<?> page, SysTenant tenant) {
        return sysTenantMapper.listByPage(page, tenant);
    }

    @Override
    public List<SysTenant> listAll(SysTenant sysTenant) {
        LambdaQueryWrapper<SysTenant> query = new LambdaQueryWrapper<>();
        if(sysTenant.getTenantType()!=null){
            query.eq(SysTenant::getTenantType,sysTenant.getTenantType());
        }
       if(sysTenant.getStatus()!=null){
           query.eq(SysTenant::getStatus,sysTenant.getStatus());
       }

        return sysTenantMapper.selectList(query);
    }
}




